#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
#include<queue>


using namespace std;

int main()
{
    int ever_size;
    int box_size;
    int one_size;
    cin >> ever_size >> box_size >> one_size;
    queue<int> ever;
    for (int i = 0; i < ever_size; i++)
    {
        int k;
        cin >> k;
        ever.push(k);
    }
    queue<int> ret;
    stack<int> box;
    int i = 0;
    while (!(ever.empty() && box.empty()))
    {
        if (box.empty())
        {
            ret.push(ever.front());
            ever.pop();
        }
        else
        {
            ret.push(box.top());
            box.pop();
        }
        while (1)
        {
            if (!box.empty() && box.top() <= ret.back())
            {
                ret.push(box.top());
                box.pop();
            }
            else if (!ever.empty() && ever.front() <= ret.back())
            {
                ret.push(ever.front());
                ever.pop();
            }
            else if (box.size() < box_size && !ever.empty())
            {
                box.push(ever.front());
                ever.pop();
            }
            else
            {
                while (ret.size() > 1)
                {
                    cout << ret.front() << ' ';
                    ret.pop();
                }
                cout << ret.front() << endl;
                ret.pop();
                break;
            }
            if (ret.size() == one_size)
            {
                while (ret.size() > 1)
                {
                    cout << ret.front() << ' ';
                    ret.pop();
                }
                cout << ret.front() << endl;
                ret.pop();
                break;
            }
           
        }
    }
    return 0;
}
